var express = require('express')
var router = express.Router()

const { getALL, getById, exec } = require('../db')

// * 根据id获取单篇文章数据进入到文章详细
//*GET/blogcontent/id
router.get('/', async (req, res) => {
  const { id } = req.query
  let sql = `select category_name,title,author,updated_time,abstract,pageviews,content from  articles LEFT JOIN categories on categories.id = articles.category_id where articles.id =${id}`
  const data = await getById(sql)
  res.send({
    code: 0,
    message: '获取单篇文章成功',
    result: data,
  })
})
module.exports = router
